#include "Drv_ADS8505.h"
#include "bitBand.h"


#define RD_ADS8505_D0()    Pin()
#define RD_ADS8505_D1()    Pin()
#define RD_ADS8505_D2()    Pin()
#define RD_ADS8505_D3()    Pin()
#define RD_ADS8505_D4()    Pin()
#define RD_ADS8505_D5()    Pin()
#define RD_ADS8505_D6()    Pin()
#define RD_ADS8505_D7()    Pin()
#define RD_ADS8505_D8()    Pin()
#define RD_ADS8505_D9()    Pin()
#define RD_ADS8505_D10()   Pin()
#define RD_ADS8505_D11()   Pin()
#define RD_ADS8505_D12()   Pin()
#define RD_ADS8505_D13()   Pin()


uint16_t cnt_sampling;
uint16_t cnt_target;
uint16_t buf_AD_Data[2000];
float real_AD_Data[2000];
uint8_t  cntEndFlag;


uint16_t ADS8505_readData()
{
  uint16_t tmp;

  tmp = (RD_ADS8505_D13()  << 13) +
        (RD_ADS8505_D12()  << 12) +
        (RD_ADS8505_D11()  << 11) +
        (RD_ADS8505_D10()  << 10) +
        (RD_ADS8505_D9()   << 9 ) +
        (RD_ADS8505_D8()   << 8 ) +
        (RD_ADS8505_D7()   << 7 ) +
        (RD_ADS8505_D6()   << 6 ) +
        (RD_ADS8505_D5()   << 5 ) +
        (RD_ADS8505_D4()   << 4 ) +
        (RD_ADS8505_D3()   << 3 ) +
        (RD_ADS8505_D2()   << 2 ) +
        (RD_ADS8505_D1()   << 1 ) +
        (RD_ADS8505_D0()   << 0 );

  return tmp;
}

void ADS8505_getDataStream(uint16_t num)
{
  cnt_sampling = 0;
  cnt_target = num;
  cntEndFlag = 0;
  // HAL_TIM_PWM_Start_IT(&htim8, TIM_CHANNEL_1);
  while(!cntEndFlag);
}

void ADS8505_transData(uint16_t num)
{
  uint32_t i;
  
  for(i = 0; i < num; ++i)
  {
    // real_AD_Data[i] = (2048 - buf_AD_Data[i + VALID_DATA_SHIFT]) * 5.0 / 2048;
  }
}

/******************************************
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 *******************************************/